<?php
use \phiction\tester as t;
use \phiction\mapper as m;

return [
    'desugar-path' => function () {
        t::must_equal(m::desugar_request_path("/post/list/1"), [
            'type' => 'page',
            'module' => 'post',
            'action' => ['list', '1'],
        ]);
        t::must_equal(m::desugar_request_path("/page/post/list/1"), [
            'type' => 'page',
            'module' => 'post',
            'action' => ['list', '1'],
        ]);
        t::must_equal(m::desugar_request_path("/api/post/add"), [
            'type' => 'api',
            'module' => 'post',
            'action' => ['add'],
        ]);
        t::must_equal(m::desugar_request_path("/"), [
            'type' => 'page',
            'module' => '',
            'action' => [],
        ]);
        t::must_equal(m::desugar_request_path("/"), m::desugar_request_path(""));
        t::must_equal(m::desugar_request_path("/"), m::desugar_request_path("/page"));
        t::must_equal(m::desugar_request_path("/"), m::desugar_request_path("/page/"));
    },
    '!desugar-path-root-api' => function () {
        m::desugar_request_path("/api");
    },
    '!desugar-path-root-api-root' => function () {
        m::desugar_request_path("/api/");
    },
];

